// /**
// //  * Magento
//  *
//  * NOTICE OF LICENSE
//  *
//  * This source file is subject to the Academic Free License (AFL 3.0)
//  * that is bundled with this package in the file LICENSE_AFL.txt.
//  * It is also available through the world-wide-web at this URL:
//  * http://opensource.org/licenses/afl-3.0.php
//  * If you did not receive a copy of the license and are unable to
//  * obtain it through the world-wide-web, please send an email
//  * to license@magentocommerce.com so we can send you a copy immediately.
//  *
//  * DISCLAIMER
//  *
//  * Do not edit or add to this file if you wish to upgrade Magento to newer
//  * versions in the future. If you wish to customize Magento for your
//  * needs please refer to http://www.magentocommerce.com for more information.
//  *
//  * @category    design
//  * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
//  * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
//  */

.table(
    @_table-width: @table-width,
    @_cell-padding-vertical: @table-cell-padding-vertical,
    @_cell-padding-horizontal: @table-cell-padding-horizontal,
    @_table-margin-bottom: @table-margin-bottom
) {
    border-collapse: collapse;
    border-spacing: 0;
    .css(margin-bottom, @_table-margin-bottom);
    max-width: 100%;
    .css(width, @_table-width);
    th {
        text-align: left;
    }
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                vertical-align: top;
            }
        }
    }
    > thead > tr {
        > th,
        > td {
            vertical-align: bottom;
        }
    }
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                .css(padding, @_cell-padding-vertical @_cell-padding-horizontal);
            }
        }
    }
}

.table-typography(
     @_table-td-font-size: @table-td-font-size,
     @_table-td-color: @table-td-color,
     @_table-td-font-family: @table-td-font-family,
     @_table-td-font-weight: @table-td-font-weight,
     @_table-td-line-height: @table-td-line-height,
     @_table-td-font-style: @table-td-font-style,
     @_table-th-font-size: @table-th-font-size,
     @_table-th-color: @table-th-color,
     @_table-th-font-family: @table-th-font-family,
     @_table-th-font-weight: @table-th-font-weight,
     @_table-th-line-height: @table-th-line-height,
     @_table-th-font-style: @table-th-font-style
) {
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > td {
                .typography (
                    @_font-size: @_table-td-font-size,
                    @_color: @_table-td-color,
                    @_font-family: @_table-td-font-family,
                    @_font-weight: @_table-td-font-weight,
                    @_line-height: @_table-td-line-height,
                    @_font-style: @_table-td-font-style
                );
            }
            > th {
                .typography (
                    @_font-size: @_table-th-font-size,
                    @_color: @_table-th-color,
                    @_font-family: @_table-th-font-family,
                    @_font-weight: @_table-th-font-weight,
                    @_line-height: @_table-th-line-height,
                    @_font-style: @_table-th-font-style
                );
            }
        }
    }
}

.table-bg(
    @_table-bg: @table-bg,
    @_table-head-bg: @table-head-bg,
    @_table-foot-bg: @table-foot-bg,
    @_table-td-bg: @table-td-bg,
    @_table-body-th-bg: @table-body-th-bg
) {
    .css(background, @_table-bg);
    > thead {
        .css(background, @_table-head-bg);
    }
    > tfoot {
        .css(background, @_table-foot-bg);
    }
    > tbody > tr > td {
        .css(background, @_table-td-bg);
    }
    > tbody > tr >th {
        .css(background, @_table-body-th-bg);
    }
}

.table-resize(
    @_td-padding-top: @table-cell-padding-vertical / 2,
    @_td-padding-right: @table-cell-padding-horizontal / 2,
    @_td-padding-bottom: @_td-padding-top,
    @_td-padding-left: @_td-padding-right,
    @_th-padding-top: @_td-padding-top,
    @_th-padding-right: @_td-padding-right,
    @_th-padding-bottom: @_td-padding-top,
    @_th-padding-left: @_td-padding-right
) {
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > td {
                .css(padding, @_td-padding-top @_td-padding-right @_td-padding-bottom @_td-padding-left);
            }
            > th {
                .css(padding, @_th-padding-top @_th-padding-right @_th-padding-bottom @_th-padding-left);
            }
        }
    }
}

.table-bordered(
    @_type: normal,
    @_border-width: @table-border-width,
    @_border-style: @table-border-style,
    @_border-color: @table-border-color
) when (@_type = normal){
    .css(border, @_border-width @_border-style @_border-color);
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                .css(border, @_border-width @_border-style @_border-color);
            }
        }
    }
}

.table-bordered(
    @_type: normal,
    @_border-width: @table-border-width,
    @_border-style: @table-border-style,
    @_border-color: @table-border-color
) when (@_type = horizontal){
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                .css(border-top, @_border-width @_border-style @_border-color);
            }
        }
    }
    > caption + thead,
    > colgroup + thead,
    > thead:first-child {
        > tr:first-child {
            > th,
            > td {
                border-top: 0;
            }
        }
    }
    > tbody + tbody {
        .css(border-top, @_border-width @_border-style @_border-color);
    }
}

.table-bordered(
    @_type: normal,
    @_border-width: @table-border-width,
    @_border-style: @table-border-style,
    @_border-color: @table-border-color
) when (@_type = vertical){
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                .css(border-left, @_border-width @_border-style @_border-color);
                &:first-child {
                    border-left: none;
                }
            }
        }
    }
}

.table-bordered(
    @_type: normal,
    @_border-width: @table-border-width,
    @_border-style: @table-border-style,
    @_border-color: @table-border-color
) when (@_type = light){
    border: none;
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                border: none;
            }
        }
    }
    > thead {
        > tr {
            > th,
            > td {
                .css(border-bottom, @_border-width @_border-style @_border-color);
            }
        }
    }
}

.table-bordered(
    @_type: normal,
    @_border-width: @table-border-width,
    @_border-style: @table-border-style,
    @_border-color: @table-border-color
) when (@_type = clear){
    border: none;
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th,
            > td {
                border: none;
            }
        }
    }
}

.table-striped(
    @_stripped-bg: @table-cell-bg-stripped,
    @_stripped-color: @table-cell-color-stripped,
    @_stripped-direction: horizontal,
    @_stripped-highlight: odd
    ) when (@_stripped-highlight = odd) and (@_stripped-direction = horizontal){
    > tbody > tr:nth-child(odd) {
        > td,
        > th {
            .css(background, @_stripped-bg);
            .css(color, @_stripped-color);
        }
    }
}

.table-striped(
    @_stripped-bg: @table-cell-bg-stripped,
    @_stripped-color: @table-cell-color-stripped,
    @_stripped-direction: horizontal,
    @_stripped-highlight: odd
) when (@_stripped-highlight = even) and (@_stripped-direction = horizontal) {
    > tbody > tr:nth-child(even) {
        > td,
        > th {
            .css(background, @_stripped-bg);
            .css(color, @_stripped-color);
        }
    }
}

.table-striped(
    @_stripped-bg: @table-cell-bg-stripped,
    @_stripped-color: @table-cell-color-stripped,
    @_stripped-direction: horizontal,
    @_stripped-highlight: odd
) when (@_stripped-highlight = odd) and (@_stripped-direction = vertical) {
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th:nth-child(odd),
            > td:nth-child(odd) {
                .css(background, @_stripped-bg);
                .css(color, @_stripped-color);
            }
        }
    }
}

.table-striped(
    @_stripped-bg: @table-cell-bg-stripped,
    @_stripped-color: @table-cell-color-stripped,
    @_stripped-direction: horizontal,
    @_stripped-highlight: odd
) when (@_stripped-highlight = even) and (@_stripped-direction = vertical) {
    > thead,
    > tbody,
    > tfoot {
        > tr {
            > th:nth-child(even),
            > td:nth-child(even) {
                .css(background, @_stripped-bg);
                .css(color, @_stripped-color);
            }
        }
    }
}

.table-hover(
    @_cell-bg-hover: @table-cell-bg-hover,
    @_cell-odd-bg-hover: @_cell-bg-hover
) {
    > tbody > tr:nth-child(even):hover {
        > td,
        > th {
            .css(background, @_cell-bg-hover);
        }
    }
    > tbody > tr:nth-child(odd):hover {
        > td,
        > th {
            .css(background, @_cell-odd-bg-hover);
        }
    }
}

.table-overflow() {
    width: 100%;
    .css(margin-bottom, @table-margin-bottom);
    overflow-y: hidden;
    overflow-x: auto;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    -webkit-overflow-scrolling: touch;
    > table {
        > thead,
        > tbody,
        > tfoot {
            > tr {
                > th,
                > td {
                    //white-space: nowrap;
                }
            }
        }
    }
}

.table-responsive(
    @_table-bg-responsive: @table-bg-responsive,
    @_table-th-bg-responsive: @table-head-bg,
    @_reset-table-striped: false,
    @_reset-table-hover: false
) when (@_reset-table-striped = false) and (@_reset-table-hover = false){
    ._responsive-table(@_table-bg-responsive: @_table-bg-responsive);
    > tbody > tr > th {
        .css(background-color, @_table-th-bg-responsive);
    }
}

.table-responsive(
    @_table-bg-responsive: @table-bg-responsive,
    @_table-th-bg-responsive: @table-head-bg,
    @_reset-table-striped: false,
    @_reset-table-hover: false
) when (@_reset-table-striped = true) and (@_reset-table-hover = true){
    .table-striped(@_stripped-bg: @_table-bg-responsive);
    .table-hover(
        @_cell-bg-hover: @_table-bg-responsive,
        @_cell-odd-bg-hover: @_table-bg-responsive
        );
    ._responsive-table(@_table-bg-responsive: @_table-bg-responsive);
    > tbody > tr > th {
        background-color: @_table-th-bg-responsive !important;
    }
}

.table-responsive(
    @_table-bg-responsive: @table-bg-responsive,
    @_table-th-bg-responsive: @table-head-bg,
    @_reset-table-striped: false,
    @_reset-table-hover: false
) when (@_reset-table-striped = true) and (@_reset-table-hover = false){
    .table-striped(@_stripped-bg: @_table-bg-responsive);
    ._responsive-table(@_table-bg-responsive: @_table-bg-responsive);
    .css(background-color, @_table-th-bg-responsive);
}

.table-responsive(
    @_table-bg-responsive: @table-bg-responsive,
    @_table-th-bg-responsive: @table-head-bg,
    @_reset-table-striped: false,
    @_reset-table-hover: false
) when (@_reset-table-striped = false) and (@_reset-table-hover = true){
    .table-hover(
        @_cell-bg-hover: @_table-bg-responsive,
        @_cell-odd-bg-hover: @_table-bg-responsive
        );
    ._responsive-table(@_table-bg-responsive: @_table-bg-responsive);
    > tbody > tr > th {
        background-color: @_table-th-bg-responsive !important;
    }
}

.table-caption(
    @_table-caption-hide: false,
    @_table-caption-font-size: @table-caption-font-size,
    @_table-caption-color: @table-caption-color,
    @_table-caption-font-family: @table-caption-font-family,
    @_table-caption-font-weight: @table-caption-font-weight,
    @_table-caption-font-style: @table-caption-font-style,
    @_table-caption-line-height: @table-caption-line-height,
    @_table-caption-alignment:  @table-caption-alignment,
    @_table-caption-margin-top: @table-caption-margin-top,
    @_table-caption-margin-bottom: @table-caption-margin-bottom
) when (@_table-caption-hide = false){
    > caption {
        .typography (
            @_table-caption-font-size,
            @_table-caption-color,
            @_table-caption-font-family,
            @_table-caption-font-weight,
            @_table-caption-line-height,
            @_table-caption-font-style
        );
        .css(text-align, @_table-caption-alignment);
        .css(margin-top, @_table-caption-margin-top);
        .css(margin-bottom, @_table-caption-margin-bottom);
    }
}

.table-caption(
    @_table-caption-hide: false,
    @_table-caption-font-size: @table-caption-font-size,
    @_table-caption-color: @table-caption-color,
    @_table-caption-font-family: @table-caption-font-family,
    @_table-caption-font-weight: @table-caption-font-weight,
    @_table-caption-line-height: @table-caption-line-height,
    @_table-caption-font-style: @table-caption-font-style,
    @_table-caption-alignment:  @table-caption-alignment,
    @_table-caption-margin-top: @table-caption-margin-top,
    @_table-caption-margin-bottom: @table-caption-margin-bottom
) when (@_table-caption-hide = true) {
    > caption {
        .visually-hidden();
    }
}

._responsive-table(@_table-bg-responsive: @_table-bg-responsive) {
    border: none;
    .css(background, @_table-bg-responsive);
    > thead > tr > th {
        display: none;
    }
    > tbody > tr {
        td,
        th {
            display: block;
            padding: (@table-cell-padding-vertical / 2) @table-cell-padding-horizontal;
            border-bottom: none;
            &:before {
                content: attr(data-th)"";
                display: inline-block;
                .css(padding-right, @table-cell-padding-horizontal);
                .typography (
                    @_font-size: @table-th-font-size,
                    @_color: @table-th-color,
                    @_font-family: @table-th-font-family,
                    @_font-weight: @table-th-font-weight,
                    @_line-height: @table-th-line-height,
                    @_font-style: @table-th-font-style
                );
            }
        }
    }
    > tbody > tr > td {
        .css(background, @_table-bg-responsive);
    }
    > tfoot > tr > {
        td,
        th {
            display: block;
        }
    }
}
